﻿using System;
using Soundteller.Visual.Model;
using Soundteller.Visual.Model.Interfaces;
using Soundteller.Visual.Repositories.Interfaces;

namespace Soundteller.Visual.Repositories
{
    public class GraphicBufferRepository : MemoryRepositoryBase, IGraphicBufferRepository
    {
        public GraphicBufferRepository(IMemoryContext context)
            : base(context)
        {
        }

        public GraphicBase Peek()
        {
            if (Context.GraphicBuffer.Count == 0) return null;

            return Context.GraphicBuffer.Peek();
        }

        public GraphicBase Pop()
        {
            return Context.GraphicBuffer.Pop();
        }

        public void Push(GraphicBase graphic)
        {
            if (graphic == null) throw new ArgumentNullException("graphic");

            Context.GraphicBuffer.Push(graphic);
        }
    }
}